﻿<!DOCTYPE HTML>
<html lang="zh">
<head>
<title>WinGetStyle / WinGetExStyle - 语法 &amp; 使用 | AutoHotkey v2</title>
<meta name="description" content="The WinGetStyle and WinGetExStyle functions return the style or extended style (respectively) of the specified window." />
<meta name="ahk:equiv-v1" content="commands/WinGet.htm#Style" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
<script type="text/javascript">$(function(){0<=window.navigator.userAgent.toLowerCase().indexOf("ucbrowser")&&CaoNiMaDeUc()})</script>
</head>
<body>

<h1>WinGetStyle / WinGetExStyle</h1>

<p>分别返回指定窗口的样式或扩展样式.</p>

<pre class="Syntax">Style := <span class="func">WinGetStyle</span>(<span class="optional">WinTitle, WinText, ExcludeTitle, ExcludeText</span>)
ExStyle := <span class="func">WinGetExStyle</span>(<span class="optional">WinTitle, WinText, ExcludeTitle, ExcludeText</span>)</pre>

<h2 id="Parameters">参数</h2>
<dl>
    <dt>WinTitle</dt>
    <dd>
        <p>类型: <a href="../Concepts.htm#strings">字符串</a>, <a href="../Concepts.htm#numbers">整数</a>或<a href="../Objects.htm">对象</a></p>
        <p>识别目标窗口的窗口标题或其他条件. 请参阅 <a href="../misc/WinTitle.htm">WinTitle</a>.</p>
    </dd>
    <dt>WinText</dt>
    <dd>
        <p>类型: <a href="../Concepts.htm#strings">字符串</a></p>
        <p>如果存在, 此参数必须是目标窗口的单个文本元素的子字符串(和内置的 Window Spy 工具显示的一样). 如果 <a href="DetectHiddenText.htm">DetectHiddenText</a> 为 ON, 那么会检测隐藏文本元素.</p>
    </dd>
    <dt>ExcludeTitle</dt>
    <dd>
        <p>类型: <a href="../Concepts.htm#strings">字符串</a></p>
        <p>标题中含有此参数值的窗口将被排除.</p>
    </dd>
    <dt>ExcludeText</dt>
    <dd>
        <p>类型: <a href="../Concepts.htm#strings">字符串</a></p>
        <p>文本中含有此参数值的窗口将被排除.</p>
    </dd>
</dl>

<h2 id="Return_Value">返回值</h2>
<p>类型: <a href="../Concepts.htm#numbers">整数</a></p>
<p>这些函数分别返回指定窗口的样式或扩展样式. 如果没有匹配的窗口, 则返回一个空字符串.</p>

<h2 id="Error_Handling">错误处理</h2>
<p>如果找不到窗口, 则抛出 <a href="../objects/Error.htm#TargetError">TargetError</a>.</p>

<h2 id="Remarks">备注</h2>
<p>有关样式的部分列表, 请参阅<a href="../misc/Styles.htm">样式列表</a>.</p>
<p>鼠标光标下的窗口的 ID 可以使用 <a href="MouseGetPos.htm">MouseGetPos</a> 来获取.</p>
<p>窗口标题和文本是区分大小写的. 除非 <a href="DetectHiddenWindows.htm">DetectHiddenWindows</a> 被打开, 否则不会检测隐藏窗口.</p>

<h2 id="Related">相关</h2>
<p><a href="WinSetStyle.htm">WinSetStyle / WinSetExStyle</a>, <a href="ControlGetStyle.htm">ControlGetStyle / ControlGetExStyle</a>, <a href="../misc/Styles.htm">样式列表</a>, <a href="Win.htm">Win 函数</a>, <a href="Control.htm">Control 函数</a></p>

<h2 id="Examples">示例</h2>
<div class="ex" id="ExStyle">
<p><a class="ex_number" href="#ExStyle"></a> 确定窗口是否具有 WS_DISABLED 样式.</p>
<pre>Style := WinGetStyle("My Window Title")
if (Style &amp; 0x8000000)  <em>; 0x8000000 为 WS_DISABLED.</em>
    MsgBox "The window is disabled."</pre>
</div>

<div class="ex" id="ExExStyle">
<p><a class="ex_number" href="#ExExStyle"></a> 确定窗口是否具有 WS_EX_TOPMOST 样式(置顶).</p>
<pre>ExStyle := WinGetExStyle("My Window Title")
if (ExStyle &amp; 0x8)  <em>; 0x8 为 WS_EX_TOPMOST.</em>
    MsgBox "The window is always-on-top."</pre>
</div>

</body>
</html>